/* config-overrides.js */
const tsImportPluginFactory = require('ts-import-plugin');
const rewireSass = require('react-app-rewire-scss');
const { getLoader, injectBabelPlugin } = require("react-app-rewired");
const rewireLess = require('react-app-rewire-less');

module.exports = function override(config, env) {
    //do stuff with the webpack config...
   
    config = rewireSass(config, env);
    config = injectBabelPlugin('emotion/babel',config);
   
     const tsLoader = getLoader(
      config.module.rules,
      rule =>
        rule.loader &&
        typeof rule.loader === 'string' &&
        rule.loader.includes('ts-loader')
    );

    tsLoader.options = {
      getCustomTransformers: () => ({
        before: [ tsImportPluginFactory({
          libraryName: 'antd',
          libraryDirectory: 'es',
	    style: true,
        }) ]
      })
    };
   
    config = rewireLess.withLoaderOptions({
	javascriptEnabled: true,
	modifyVars: { "@primary-color": "#1890ff" },
    })(config, env);
  return config;
}
